import request from '@/utils/request.js'

// 登录接口
export const getLoginApi = ({ email, password }) =>
  request({
    url: 'http://116.205.180.109:3005/login',
    method: 'post',
    data: {
      email,
      password
    }
  })

// 更新用户信息接口
export const updateUserApi = ({ id, nickname, introductions }) =>
  request({
    url: 'http://116.205.180.109:3005/updateUser',
    method: 'put',
    data: {
      id,
      nickname,
      introductions
    }
  })

// 发送邮箱验证码接口
export const emailApi = (email) =>
  request({
    url: 'http://116.205.180.109:3005/sendEmail',
    method: 'post',
    data: {
      email
    }
  })

// 验证 邮箱验证码 接口 注册接口
export const registerAPi = ({ code, password, email, time }) =>
  request({
    url: 'http://116.205.180.109:3005/register',
    method: 'post',
    data: {
      code,
      password,
      email,
      time
    }
  })

// 更新用户密码接口
export const updatePwdApi = ({ code, password, email }) =>
  request({
    url: 'http://116.205.180.109:3005/updatePwd',
    method: 'post',
    data: {
      code,
      password,
      email
    }
  })
// 上传 日记 接口
export const addDiaryApi = ({ id, articleid, content, tilength, cityname, wearther, nowicon, temperature, week, time, getdate }) =>
  request({
    url: 'http://116.205.180.109:3005/addDiary',
    method: 'post',
    data: {
      id, // 用户id
      articleid, // 文章id
      content, // 文章内容
      tilength, // 文章字数
      cityname, // 发布文章城市
      wearther, // 发布文章城市天气
      nowicon, // 发布文章城市天气图标
      temperature, // 发布文章城市温度
      week, // 星期
      time, // 时间
      getdate // 年月日
    }
  })
// 上传 日记图片 接口
export const upArticleImgApi = ({ id, imgurl, content, getdate }) =>
  request({
    url: 'http://116.205.180.109:3005/upArticleImg',
    method: 'post',
    data: {
      id,
      imgurl,
      content,
      getdate
    }
  })

// 请求 用户日记 接口
export const getUserDiaryApi = (id) =>
  request({
    url: 'http://116.205.180.109:3005/getUserDiary',
    method: 'get',
    params: {
      id
    }
  })

// 删除 用户日记 接口
export const delUserDiaryApi = (id, articleid) =>
  request({
    url: 'http://116.205.180.109:3005/delUserDiary',
    method: 'delete',
    params: {
      id,
      articleid
    }
  })

// 更新 用户日记 接口
export const updateDiaryApi = (id, articleid, content, imgurl, tilength) =>
  request({
    url: 'http://116.205.180.109:3005/updateDiary',
    method: 'post',
    data: {
      id,
      articleid,
      content,
      imgurl,
      tilength
    }
  })

// 请求 用户回收站日记 接口
export const getRecycleDiaryApi = (id) =>
  request({
    url: 'http://116.205.180.109:3005/getRecycleDiary',
    method: 'get',
    params: {
      id
    }
  })

// 删除 用户回收站日记 接口
export const delRecycleDiaryApi = (id, articleid) =>
  request({
    url: 'http://116.205.180.109:3005/delRecycleDiary',
    method: 'delete',
    params: {
      id,
      articleid
    }
  })

// 恢复 用户回收站日记 接口
export const postRecycleDiaryApi = (id, articleid) =>
  request({
    url: 'http://116.205.180.109:3005/postRecycleDiary',
    method: 'post',
    data: {
      id,
      articleid
    }
  })
  // 删除 所有回收站日记 接口
export const delRecycleAllDiaryApi = (id) =>
  request({
    url: 'http://116.205.180.109:3005/delRecycleAllDiary',
    method: 'delete',
    params: {
      id
    }
  })
